<?php

error_reporting(E_ALL);
define('ROOT_PATH', dirname(dirname(__FILE__)));			//根目录绝对路径常量
date_default_timezone_set("Asia/Shanghai");

//获取函数库文件
require_once(ROOT_PATH . "/inc/function.php");
//获取DB类文件
require_once(ROOT_PATH . "/inc/mysql.class.php");
//smarty
require_once(ROOT_PATH . "/inc/Smarty/Smarty.class.php");
//数据库配置
require_once(ROOT_PATH."/inc/config.php");

//本地测试加载server_config_test.php配置文件
$server_ip = @$_SERVER['SERVER_ADDR'];
$test_servers = array('192.168.8.199','192.168.8.197');
if(in_array($server_ip, $test_servers))	
{
	include_once(ROOT_PATH . "/inc/server_config_test.php");
}
else 
{
	//定义代理平台的所有服务器
	include_once(ROOT_PATH . "/inc/server_config.php");
}
//xml转数组类
require_once(ROOT_PATH."/inc/xml.class.php");

$tmp_dir = ROOT_PATH . '/tmp/';
$templates_c_dir = ROOT_PATH . '/tmp/templates_c';

checkPath($tmp_dir);
checkFile($templates_c_dir);

class MySmarty extends Smarty 
{
   function MySmarty() 
   {
		$this->Smarty();
		
		$this->template_dir 	= "templates";
		$this->compile_dir  	= ROOT_PATH . "/tmp/templates_c/";
		$this->config_dir   	= "config/";
		$this->cache_dir    	= "cache/";
		 
		$this->left_delimiter 	= "<{"; 
		$this->right_delimiter 	= "}>"; 
		$this->caching 			= false;
		$this->debug			= false;
		$this->compile_check	= true;
		$this->cache_lifetime 	= 0;
   }
}
$T = new MySmarty;
$T->assign('webtitle','真王央服管理系统v'.CENTERVERSION);

//数据库初始化
$db = new db($Db_array[1]['dbhost'],$Db_array[1]['dbuser'],$Db_array[1]['dbpwd'],$Db_array[1]['dbname']);

session_save_path(ROOT_PATH . '/tmp/session');
session_start();


/******* 防止SQL注入 *******/
if(!get_magic_quotes_gpc()) 
{
  if(!empty($_GET))
  {
  	$_GET = addslashes_deep($_GET);
  }
  if(!empty($_POST))
  {
  	$_POST = addslashes_deep($_POST);
  }
  
  $_COOKIE = addslashes_deep($_COOKIE);
  $_REQUEST = addslashes_deep($_REQUEST);
}



?>